<template>
	<div class="willplay">
		<div class="movie-line">
			<div class="upcoming">即将上映</div>
		</div>
		<ul>
			<li v-for='item in willList'>
				<router-link :to="{name:'detail',params:{'id':item.id}}">
					<img :src="item.cover.origin" alt="">
					<div class="info-box">
						<p class="mvname">{{item.name}}</p>
						<span class="upday">{{item.premiereAt | formateDate}}</span>
					</div>
				</router-link>
			</li>
			<li class="last">
				<router-link class="more" :to="{name:'willplaying'}">
				更多即将上映电影
				</router-link>
			</li>
		</ul>
	</div>
</template>
<script>
	import $ from 'jquery';
	export default{
		data:function () {
			return {
				willList:[]
			}
		},
		filters:{
			'formateDate':function (t) {
				var time = new Date(t);
				var m = time.getMonth()+1;
				var d = time.getDate();
				return m + '月' + d + '日上映';
			}
		},
		mounted:function () {
				var that = this;
				var t = new Date().getTime();
				var willUrl = 'http://localhost:3000/will?time='+t+'&page=1&count=3';
				$.get(willUrl,function(res) {
				that.willList = res.data.films;
			});
		}
	}
</script>